package 多线程初阶.示例测试;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池的创建使用示例
 */
public class TestDemo23 {
    public static volatile int count;
    public static void main(String[] args) {
        ExecutorService pool= Executors.newFixedThreadPool(5);
        while (true){
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(count++);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }
}
